package fschmidt.util.log4j;

import org.apache.log4j.spi.LoggingEvent;
import org.apache.log4j.spi.TriggeringEventEvaluator;


public final class CountingEvaluator implements TriggeringEventEvaluator {
	private final int limit;
	private int count = 0;

	public CountingEvaluator(int limit) {
		this.limit = limit;
	}

	public boolean isTriggeringEvent(LoggingEvent event) {
		if( ++count < limit ) {
			return false;
		} else {
			count = 0;
			return true;
		}
	}
}
